import 'package:built_collection/built_collection.dart';
import 'package:mobile_app.core/core/domain/entities/learning_content/collection_list_item/collection_list_item.dart';

abstract class FindCustomCollectionFolder {
  CustomCollectionFolder? call({
    required String customCollectionFolderId,
    required BuiltList<CollectionListItem> collectionListItems,
  });
}

class FindCustomCollectionFolderImpl implements FindCustomCollectionFolder {
  const FindCustomCollectionFolderImpl();

  @override
  CustomCollectionFolder? call({
    required String customCollectionFolderId,
    required BuiltList<CollectionListItem> collectionListItems,
  }) {
    for (final collectionListItem in collectionListItems) {
      if (collectionListItem is CustomCollectionFolder) {
        final customCollectionFolder = collectionListItem;

        if (customCollectionFolder.id == customCollectionFolderId) {
          return customCollectionFolder;
        }
      }
    }

    return null;
  }
}